home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / fsio / fsioStreamOpTable.c < prev   
C/C++ Source or Header  |  1992-12-18  |  10KB  |  317 lines

  1. /* 
  2.  * fsStreamOpTable.c --
  3.  *
  4.  *    The skeletons for the Stream Operation table, the Srv Open table,
  5.  *    and the routines for initializing entries in these tables.
  6.  *
  7.  * Copyright 1987 Regents of the University of California
  8.  * All rights reserved.
  9.  * Permission to use, copy, modify, and distribute this
  10.  * software and its documentation for any purpose and without
  11.  * fee is hereby granted, provided that the above copyright
  12.  * notice appear in all copies.  The University of California
  13.  * makes no representations about the suitability of this
  14.  * software for any purpose.  It is provided "as is" without
  15.  * express or implied warranty.
  16.  */
  17.  
  18. #ifndef lint
  19. static char rcsid[] = "$Header: /cdrom/src/kernel/Cvsroot/kernel/fsio/fsioStreamOpTable.c,v 9.5 92/08/10 17:27:01 mgbaker Exp $ SPRITE (Berkeley)";
  20. #endif not lint
  21.  
  22.  
  23. #include <sprite.h>
  24. #include <fs.h>
  25. #include <fsconsist.h>
  26. #include <fsio.h>
  27. #include <fsutil.h>
  28. #include <fsioFile.h>
  29. #include <fsioDevice.h>
  30. #include <fsioPipe.h>
  31. #include <fspdev.h>
  32.  
  33.  
  34. /*
  35.  * File type server open routine table:
  36.  *    The OpenOps consists of a single routine, 'nameOpen', which
  37.  *    is invoked on the file server after pathname resolution has
  38.  *    obtained the I/O handle for the local file that represents
  39.  *    the name of some object.  The nameOpen routine is invoked
  40.  *    depending on the type of the local file (file, directory, device, etc.)
  41.  *    The nameOpen routine does preliminary setup in anticipation
  42.  *    of opening an I/O stream to the object.
  43.  *
  44.  * THIS ARRAY INDEXED BY FILE TYPE. 
  45.  */
  46. #define    FS_NUM_FILE_TYPE    (FS_XTRA_FILE+1)
  47. Fsio_OpenOps fsio_OpenOpTable[FS_NUM_FILE_TYPE];
  48.  
  49. /*
  50.  * Stream type specific routine table.  See fsOpTable.h for an explaination
  51.  *    of the calling sequence for each routine.
  52.  *
  53.  * THIS ARRAY INDEXED BY STREAM TYPE.  Do not arbitrarily insert entries.
  54.  */
  55. Fsio_StreamTypeOps fsio_StreamOpTable[FSIO_NUM_STREAM_TYPES];
  56.  
  57.  
  58. /*
  59.  * Simple arrays are used to map between local and remote types.
  60.  */
  61. int fsio_RmtToLclType[FSIO_NUM_STREAM_TYPES] = {
  62.     FSIO_STREAM,             /* FSIO_STREAM */
  63.     FSIO_LCL_FILE_STREAM,        /* FSIO_LCL_FILE_STREAM */
  64.     FSIO_LCL_FILE_STREAM,        /* FSIO_RMT_FILE_STREAM */
  65.     FSIO_LCL_DEVICE_STREAM,    /* FSIO_LCL_DEVICE_STREAM */
  66.     FSIO_LCL_DEVICE_STREAM,    /* FSIO_RMT_DEVICE_STREAM */
  67.     FSIO_LCL_PIPE_STREAM,        /* FSIO_LCL_PIPE_STREAM */
  68.     FSIO_LCL_PIPE_STREAM,        /* FSIO_RMT_PIPE_STREAM */
  69.     FSIO_CONTROL_STREAM,        /* FSIO_CONTROL_STREAM */
  70.     FSIO_SERVER_STREAM,        /* FSIO_SERVER_STREAM */
  71.     FSIO_LCL_PSEUDO_STREAM,    /* FSIO_LCL_PSEUDO_STREAM */
  72.     FSIO_LCL_PSEUDO_STREAM,    /* FSIO_RMT_PSEUDO_STREAM */
  73.     FSIO_PFS_CONTROL_STREAM,    /* FSIO_PFS_CONTROL_STREAM */
  74.     FSIO_LCL_PSEUDO_STREAM,    /* FSIO_PFS_NAMING_STREAM */
  75.     FSIO_LCL_PFS_STREAM,        /* FSIO_LCL_PFS_STREAM */
  76.     FSIO_LCL_PFS_STREAM,        /* FSIO_RMT_PFS_STREAM */
  77.     FSIO_CONTROL_STREAM,        /* FSIO_RMT_CONTROL_STREAM */
  78.     FSIO_PASSING_STREAM,        /* FSIO_PASSING_STREAM */
  79. #ifdef INET
  80.     FSIO_RAW_IP_STREAM,        /* FSIO_RAW_IP_STREAM */
  81.     FSIO_UDP_STREAM,        /* FSIO_UDP_STREAM */
  82.     FSIO_TCP_STREAM,        /* FSIO_TCP_STREAM */
  83. #endif /* INET */
  84.  
  85. };
  86.  
  87. int fsio_LclToRmtType[FSIO_NUM_STREAM_TYPES] = {
  88.     FSIO_STREAM,             /* FSIO_STREAM */
  89.     FSIO_RMT_FILE_STREAM,        /* FSIO_LCL_FILE_STREAM */
  90.     FSIO_RMT_FILE_STREAM,        /* FSIO_RMT_FILE_STREAM */
  91.     FSIO_RMT_DEVICE_STREAM,    /* FSIO_LCL_DEVICE_STREAM */
  92.     FSIO_RMT_DEVICE_STREAM,    /* FSIO_RMT_DEVICE_STREAM */
  93.     FSIO_RMT_PIPE_STREAM,        /* FSIO_LCL_PIPE_STREAM */
  94.     FSIO_RMT_PIPE_STREAM,        /* FSIO_RMT_PIPE_STREAM */
  95.     FSIO_CONTROL_STREAM,        /* FSIO_CONTROL_STREAM */
  96.     -1,                /* FSIO_SERVER_STREAM */
  97.     FSIO_RMT_PSEUDO_STREAM,    /* FSIO_LCL_PSEUDO_STREAM */
  98.     FSIO_RMT_PSEUDO_STREAM,    /* FSIO_RMT_PSEUDO_STREAM */
  99.     FSIO_PFS_CONTROL_STREAM,    /* FSIO_PFS_CONTROL_STREAM */
  100.     FSIO_PFS_NAMING_STREAM,    /* FSIO_PFS_NAMING_STREAM */
  101.     FSIO_RMT_PFS_STREAM,        /* FSIO_LCL_PFS_STREAM */
  102.     FSIO_RMT_PFS_STREAM,        /* FSIO_RMT_PFS_STREAM */
  103.     FSIO_RMT_CONTROL_STREAM,    /* FSIO_RMT_CONTROL_STREAM */
  104.     FSIO_PASSING_STREAM,        /* FSIO_PASSING_STREAM */
  105. #ifdef INET
  106.     FSIO_RAW_IP_STREAM,        /* FSIO_RAW_IP_STREAM */
  107.     FSIO_UDP_STREAM,        /* FSIO_UDP_STREAM */
  108.     FSIO_TCP_STREAM,        /* FSIO_TCP_STREAM */
  109. #endif /* INET */
  110. };
  111.  
  112.  
  113. /*
  114.  * This array contains type-specific functions for the recovery test
  115.  * statistics syscall.
  116.  */
  117. extern    int    Fsrmt_FileRecovTestUseCount();
  118. extern    int    Fsrmt_FileRecovTestNumCacheBlocks();
  119. extern    int    Fsrmt_FileRecovTestNumDirtyCacheBlocks();
  120. Fsio_RecovTestInfo    fsio_StreamRecovTestFuncs[FSIO_NUM_STREAM_TYPES] = {
  121.     /* FSIO_STREAM */
  122.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  123.     /* FSIO_LCL_FILE_STREAM */
  124.     { Fsio_FileRecovTestUseCount, Fsio_FileRecovTestNumCacheBlocks,
  125.       Fsio_FileRecovTestNumDirtyCacheBlocks },
  126.     /* FSIO_RMT_FILE_STREAM */
  127.     { Fsrmt_FileRecovTestUseCount, Fsrmt_FileRecovTestNumCacheBlocks,
  128.       Fsrmt_FileRecovTestNumDirtyCacheBlocks},
  129.     /* FSIO_LCL_DEVICE_STREAM */
  130.     { Fsio_DeviceRecovTestUseCount, (int (*)()) NIL, (int (*)()) NIL },
  131.     /* FSIO_RMT_DEVICE_STREAM */
  132.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  133.     /* FSIO_LCL_PIPE_STREAM */
  134.     { Fsio_PipeRecovTestUseCount, (int (*)()) NIL, (int (*)()) NIL },
  135.     /* FSIO_RMT_PIPE_STREAM */
  136.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  137.     /* FSIO_CONTROL_STREAM */
  138.     { Fspdev_ControlRecovTestUseCount, (int (*)()) NIL, (int (*)()) NIL },
  139.     /* FSIO_SERVER_STREAM */
  140.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  141.     /* FSIO_LCL_PSEUDO_STREAM */
  142.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  143.     /* FSIO_RMT_PSEUDO_STREAM */
  144.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  145.     /* FSIO_PFS_CONTROL_STREAM */
  146.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  147.     /* FSIO_PFS_NAMING_STREAM */
  148.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  149.     /* FSIO_LCL_PFS_STREAM */
  150.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  151.     /* FSIO_RMT_PFS_STREAM */
  152.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  153.     /* FSIO_RMT_CONTROL_STREAM */
  154.     { Fspdev_ControlRecovTestUseCount, (int (*)()) NIL, (int (*)()) NIL },
  155.     /* FSIO_PASSING_STREAM */
  156.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  157. #ifdef INET
  158.     /* FSIO_RAW_IP_STREAM */
  159.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  160.     /* FSIO_UDP_STREAM */
  161.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  162.     /* FSIO_TCP_STREAM */
  163.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  164. #endif /* INET */
  165. };
  166.  
  167. /*
  168.  *----------------------------------------------------------------------
  169.  *
  170.  * Fsio_InstallStreamOps --
  171.  *
  172.  *    Install the stream operation routines for a specified stream type.
  173.  *    
  174.  *    The stream operations are the main set of operations on objects.
  175.  *    These include operations for I/O, migration, recovery, and
  176.  *    garbage collection.
  177.  *
  178.  * Results:
  179.  *    None.
  180.  *
  181.  * Side effects:
  182.  *    fsio_StreamOpTable modified.
  183.  *
  184.  *----------------------------------------------------------------------
  185.  */
  186. void
  187. Fsio_InstallStreamOps(streamType, streamOpsPtr)
  188.     int        streamType;     /* Stream type to install operations for. */
  189.     Fsio_StreamTypeOps *streamOpsPtr; /* Operations for stream. */
  190. {
  191.     fsio_StreamOpTable[streamType] = *streamOpsPtr;
  192. }
  193.  
  194. /*
  195.  *----------------------------------------------------------------------
  196.  *
  197.  * Fsio_InstallSrvOpenOp --
  198.  *
  199.  *    Install file server open procedure for a specified file type.
  200.  *
  201.  *    The server open procedure is called after pathname resolution
  202.  *    has obtained the I/O handle for the local file that represents
  203.  *    the name of the object.  The server open procedure does preliminary
  204.  *    open-time setup for files of its particular type (file, directory,
  205.  *    device, pseudo-device, remote link, etc.).
  206.  *
  207.  * Results:
  208.  *    None.
  209.  *
  210.  * Side effects:
  211.  *    fsio_OpenOpTable modified.
  212.  *
  213.  *----------------------------------------------------------------------
  214.  */
  215.  
  216. void
  217. Fsio_InstallSrvOpenOp(fileType, openOpsPtr)
  218.     int        fileType;     /* File type to install operations for. */
  219.     Fsio_OpenOps  *openOpsPtr;     /* Operations for file type. */
  220.  
  221. {
  222.     fsio_OpenOpTable[fileType] = *openOpsPtr;
  223. }
  224.  
  225. /*
  226.  *----------------------------------------------------------------------
  227.  *
  228.  * Fsio_NullProc --
  229.  *
  230.  *    Null procedure for entries in Fsio_StreamTypeOps table.
  231.  *
  232.  * Results:
  233.  *    SUCCESS.
  234.  *
  235.  * Side effects:
  236.  *    None.
  237.  *
  238.  *----------------------------------------------------------------------
  239.  */
  240.  
  241. ReturnStatus
  242. Fsio_NullProc()
  243. {
  244.     return(SUCCESS);
  245. }
  246.  
  247. /*
  248.  *----------------------------------------------------------------------
  249.  *
  250.  * Fsio_NoProc --
  251.  *
  252.  *    No procedure for entries in Fsio_StreamTypeOps table. This is always
  253.  *    returns failure.
  254.  *
  255.  * Results:
  256.  *    FAILURE.
  257.  *
  258.  * Side effects:
  259.  *    None.
  260.  *
  261.  *----------------------------------------------------------------------
  262.  */
  263. ReturnStatus
  264. Fsio_NoProc()
  265. {
  266.     return(FAILURE);
  267. }
  268.  
  269. /*
  270.  *----------------------------------------------------------------------
  271.  *
  272.  *  Fsio_NullClientKill --
  273.  *
  274.  *      Minimum procedure for client kill stream operation.
  275.  *
  276.  * Results:
  277.  *    None
  278.  *
  279.  * Side effects:
  280.  *    Handle unlocked.
  281.  *
  282.  *----------------------------------------------------------------------
  283.  */
  284.  
  285. /*ARGSUSED*/
  286. void
  287. Fsio_NullClientKill(hdrPtr, clientID)
  288.     Fs_HandleHeader *hdrPtr;
  289.     int clientID;
  290. {
  291.     Fsutil_HandleUnlock(hdrPtr);
  292. }
  293.  
  294. /*
  295.  *----------------------------------------------------------------------
  296.  *
  297.  * Fsio_NoHandle --
  298.  *
  299.  *    Stub for a stream ops client verify routine that will always fail.
  300.  *
  301.  * Results:
  302.  *    A NILL FsHanldeHeader.
  303.  *
  304.  * Side effects:
  305.  *    None.
  306.  *
  307.  *----------------------------------------------------------------------
  308.  */
  309.  
  310. Fs_HandleHeader *
  311. Fsio_NoHandle()
  312. {
  313.     return((Fs_HandleHeader *)NIL);
  314. }
  315.  
  316.  
  317.